using M13;
using UnityEngine;
using M13.Game.Entity;
using M13.Game.Item;
using M13.Game.Item.Weapon;
using M13.GameSystem;
using M13.Phys;
using QFramework;

namespace Test
{
    public class TestEntity : Entity
    {
        public AABBCollider collider;
        IInputCtrlSystem _inputCtrlSystem;
        public float moveSpeed;
        private void Start()
        {
            collider = GetComponent<AABBCollider>();
            _inputCtrlSystem = this.GetSystem<IInputCtrlSystem>();
        }
        
        private void Update()
        {
            this.GetModel<IPlayerModal>().PlayerPos.Value = transform.position;
        }

        protected override void FixedUpdate()
        {
            Vector3 axis = new Vector3(_inputCtrlSystem.AxisXInput,0, _inputCtrlSystem.AxisYInput);
            collider.SimpleMove(axis.normalized * moveSpeed);
            
            if(_inputCtrlSystem.Execute0Input != 0f) collider.SimpleMove(Vector3.up * 10);
        }
        
        public override bool CanOperate(OperateKey key, Item item)
        {
            return true;
        }
        public override void Operate(OperateKey key, Entity op)
        {
            
        }
        public override void Operate(OperateKey operateKey, Entity operatorEntity, Item item)
        {
            if(item == null) return;
            if (operateKey == OperateKey.L && item.ItemProperties.ItemType == ItemType.Weapon)
            {
                CurrentHealthPoints -= ((Weapon)item).WeaponProperties.WeaponDamage;
            }
        }

        protected override void OnDie()
        {
            
        }
    }
}